package com.example.demo.model;

import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "user_presence")
public class UserPresence {
    @Id
    @Column(name = "user_id")
    private Long userId;

    @Column(name = "is_online")
    private Boolean isOnline = false;

    @Column(name = "last_seen")
    private LocalDateTime lastSeen;

    @Column(name = "current_session_id")
    private String currentSessionId;

    @PrePersist
    @PreUpdate
    protected void updateTimestamp() {
        lastSeen = LocalDateTime.now();
    }
}